﻿using KPI.Data;
using KPI.Entity;
using System;
using System.Collections.Generic;
using TYBase;

namespace KPI.Api
{
    public class LoginApi
    {
        public static R<List<OfficeInfoVO>> GetOfficeList(string userId)
        {
            try
            {
                ///curl -X POST "http://47.106.205.158:8895/luna/assist/v1/login/entry?id=1002" -H "accept: */*" -d ""
                //SecurityUtil.encryptReqData(param, appid, appSecret, true);
                LocalHttp http = new LocalHttp();
                http.SetGetData(new { id = userId }).SetBaseUri(KPIData.ServerURL).SetUrl($"/login/id_office");
                if (!http.Excute(out var data))
                {
                    return R<List<OfficeInfoVO>>.Fail("数据异常");
                }
                return data.AsModel<R<List<OfficeInfoVO>>>();


            }
            catch (Exception ex)
            {
                return R<List<OfficeInfoVO>>.Fail("数据异常");
            }
        }

        public static R<LoginVO> Login(LoginInfoDto loginInfo)
        {
            try
            {
                ///curl -X POST "http://47.106.205.158:8895/luna/assist/v1/login/entry?id=1002" -H "accept: */*" -d ""
                //SecurityUtil.encryptReqData(param, appid, appSecret, true);
                LocalHttp http = new LocalHttp();
                http.SetData(loginInfo).SetBaseUri(KPIData.ServerURL).SetUrl($"/login/entry").SetPost();
                if (!http.Excute(out var data))
                {
                    return R<LoginVO>.Fail("数据异常");
                }
                return data.AsModel<R<LoginVO>>();


            }
            catch (Exception ex)
            {
                return R<LoginVO>.Fail("数据异常");
            }
        }
    }
}
